<?php

namespace App\Http\Controllers\admin;

use App\Models\Auth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    public function __construct()
    {
        $this->middleware(['checkAdmin']);
    }

    //后台首页展示
    public function index()
    {
        $auth = session('admin.auth');
        if (is_array($auth))
            $authidArr = array_keys($auth);
        else
            $authidArr = $auth;
        $menu = (new Auth())->getAllList(2,$authidArr);
        return view('admin.index.index1',compact('menu'));
    }

    //欢迎界面
    public function welcome()
    {
        return view('admin.index.welcome');
    }

    //退出登录
    public function logout()
    {
        auth()->logout();
        return redirect(route('admin.login'))->with('success', '请重新登录!');
    }
}
